<?php

    class Application_Model_Email extends Zend_Db_Table_Abstract
    {

        protected $_name = "users";

        function init()
        {
            
        }

        public function sendMail($toEmail, $fromEmail, $fromName, $subject, $messageContent, $file = false)
        {
            $returnValue = FALSE;

            $mail = new Zend_Mail();
            $mail->setBodyHtml($messageContent)
                    ->setFrom($fromEmail, $fromName)
                    ->addTo($toEmail)
                    ->setSubject($subject);

            //prd($mail);					

            if ($file)
            {
                $at = new Zend_Mime_Part(file_get_contents($file));
                $at->filename = basename($file);
                $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                $at->encoding = Zend_Mime::ENCODING_8BIT;
                $mail->addAttachment($at);
            }

            if ($mail->send())
            {
                $returnValue = TRUE;
            }

            return $returnValue;
        }

        public function newRegisterationEmailTemplate($username, $first_name, $unsubscribe_url)
        {
//            $social_fb_url = getShareWithFacebook('Our mission is to innovate the way people shop daily. We combine your favorite brands social content & products into a cool fun shoppable magazine. All you have to do is #demandyourspot now.');
            $social_fb_url = getShareWithFacebook('http://raeken.com');
            $social_twitter_url = getShareWithTwitter('I just demanded my spot @(' . $username . ') on raeken.com. Get your username before its too late #demandyourspot @raekenshop');
            $social_vimeo_url = "#";
            $social_insta_url = "#";

            $str = '
                        <body style="background-color: #EEEEEE;
                              font-size: 11px;
                              font-family: Arial;">
                            <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="height: 30px; text-align:center; padding-top: 30px">Email not displaying correctly ? <a style="color: #F38F00;" href="#">Click Here</a> to view it in your browser</td>
                                </tr>
                            </table>
                            <table width="650" border="0" align="center" cellpadding="0" cellspacing="0" style=" background-color: #fff;">
                                <tr>
                                    <td style="border-top-left-radius: 3px;
                                        border-top-right-radius: 3px;"><table width="100%" border="0" cellspacing="0" cellpadding="4">
                                            <tr>
                                                <td width="86%" style="padding-left: 10px;">
                                                    <a style="color: #F38F00;" href="http://raeken.com">
                                                        <img src="http://raeken.com/assets/images/logo_email.png" alt="" width="78" height="19" style="padding: 3px;"/>
                                                    </a>
                                                </td>
                                                <td width="3%">
                                                    <a style="color: #F38F00;" href="https://www.facebook.com/raekenshop" target="_blank">
                                                        <img src="http://raeken.com/assets/images/fb_email.png" alt="" width="24" height="23" style="padding: 3px;"/>
                                                    </a></td>
                                                <td width="3%">
                                                    <a style="color: #F38F00;" href=" https://twitter.com/raekenshop" target="_blank">
                                                        <img src="http://raeken.com/assets/images/twt.png" alt="" width="23" height="23" style="padding: 3px;"/>
                                                    </a></td>
                                                <td width="3%">
                                                    <a style="color: #F38F00;" href="http://instagram.com/raekenshop" target="_blank">
                                                        <img src="http://raeken.com/assets/images/inst.png" alt="" width="24" height="23" style="padding: 3px;"/>
                                                    </a></td>
                                                <td width="3%">
                                                    <a style="color: #F38F00;" href="http://pinterest.com/raekenshop">
                                                        <img src="http://raeken.com/assets/images/pin.png" alt="" width="24" height="23" style="padding: 3px;"/>
                                                    </a></td>
                                            </tr>
                                        </table></td>
                                </tr>
                                <tr>
                                    <td><img src="http://raeken.com/assets/images/bg.jpg" width="650" height="238" alt=""/></td>
                                </tr>
                                <tr>
                                    <td style="padding-top: 30px;
                                        padding-right: 30px;
                                        padding-left: 30px;
                                        padding-bottom: 30px;"><p>Alright ' . $first_name . ', you claimed your spot in the revolution of online shopping!<br> 
                                            Your Raeken user name is: <strong style="color:#F7AD00">' . $username . '</strong><br>
                                            Our mission is to innovate the way people shop daily</p>
                                        <p>By integrating content from every major social media network into our magazine layout we give you an in-depth look at current trends, styling ideas and exactly what each brand is saying without ever you ever leaving the website.</p>
                                        <p>&ldquo;I want to raise the bar in online shopping & really shopping in general. I want to push the envelope & give people an unparalleled shopping experience&rdquo; -Kenny Dennis CEO of Raeken</p>
                                        <p>Call out to your social network and tell your friends to #DemandYourSpot at Raeken. 
                                            The official Raeken Store launches on June 1st. Until then, stay up to date on Raeken and the latest fashion trends by following our social media accounts and checking out our <span style="color:#F7AD00">blog.</span></p>

                                        <em>Whatever you do today make sure you are #RaisingTheBar.<br>
                                            Share your username with others.</em><br><br>
                                        <table border="0" cellpadding="0" cellspacing="0" class="table_top_padding">
                                            <tr>
                                                <td><a href="' . $social_fb_url . '" target="_blank"><img src="http://raeken.com/assets/images/button_fb_share.png" width="128" height="27" alt=""/></a></td>
                                                <td>&nbsp;</td>
                                                <td><a href="' . $social_twitter_url . '" target="_blank"><img src="http://raeken.com/assets/images/button_twitter_share.png" width="128" height="27" alt=""/></a></td>
                                            </tr>
                                        </table>
                                        <p><br>
                                            - Raeken Team
                                        </p></td>
                                </tr>
                            </table>
                            <table width="650" border="0" align="center" cellpadding="6" cellspacing="0">
                                <tr>
                                    <td height="50" align="center">Email not displaying correctly ? <a style="color: #F38F00;" href="#">Click Here</a> to view it in your browser</td>
                                </tr>
                            </table>
                        </body>
                        ';

            return $str;
        }

        public function newRegisterationEmailTemplate_old($username, $unsubscribe_url, $fbShareUrl, $twitterShareUrl)
        {
            $social_fb_url = "#";
            $social_twitter_url = "#";
            $social_vimeo_url = "#";
            $social_insta_url = "#";

            $str = '
                        <body style="margin: 0;padding: 0;font-family: helvetica;">
                            <div id="header" style="padding: 30px;background-color: #000; text-align: center;">
                                <a href="http://raeken.com"><img src="http://raeken.com/assets/images/logo.png" alt="logo"/></a>
                            </div>

                            <div  id="content" style="background-color: #fff;padding: 20px 10px;text-align: center;">
                                <h1>CONGRATULATION</h1>
                                <p style="margin: 0;">Hey ' . $username . ', Just DemandedYour Spot on Raeken.com Share Your username on others on</p>
                                <p style="margin: 0;">Share your username with others on</p>
                                <br/>

                                <p style="background-color: #3C5C99;
                                   border-radius: 30px 0 0 30px;
                                   display: inline-block;
                                   height: 40px;
                                   margin: 0 0 0 0;
                                   width: 22px;"></p>
                                <a href="' . $fbShareUrl . '" id="facebook-share" style="display: inline-block;text-decoration: none;background-color: #3c5c99;color: #fff;margin-left: -8px;">
                                    <img src="http://raeken.com/assets/images/fb.png" alt="Facebook" style="width: 40px;"/><span style="font-size: 14px; font-weight: bold;vertical-align: top;padding: 11px 15px 0;display: inline-block;">Share on Facebook</span>
                                </a>
                                <p style="background-color: #3C5C99;
                                   border-radius: 0 30px 30px 0;
                                   display: inline-block;
                                   height: 40px;
                                   margin: 0 0 0 -6px;
                                   width: 22px;"></p>

                                <p style="background-color: #34aaea;
                                   border-radius: 30px 0 0 30px;
                                   display: inline-block;
                                   height: 40px;
                                   margin: 0 0 0 0;
                                   width: 22px;"></p>
                                <a href="' . $twitterShareUrl . '" id="twitter-share" style="display: inline-block;text-decoration: none;color: #fff;background-color: #34aaea; margin-left: -8px;">
                                    <img src="http://raeken.com/assets/images/twit.png" alt="Twitter" style="width: 40px;"/><span style="font-size: 14px; font-weight: bold;vertical-align: top;padding: 11px 15px 0;display: inline-block;">Share on Twitter</span>
                                </a>
                                <p style="background-color: #34aaea;
                                   border-radius: 0 30px 30px 0;
                                   display: inline-block;
                                   height: 40px;
                                   margin: 0 0 0 -6px;
                                   width: 22px;"></p>

                                <p>and keep an eye on your inbox for more #RaekenShop updates.</p>
                            </div>

                            <div id="footer" style="background-color: #000;padding-top: 10px;color: #fff;text-align: center;padding-bottom: 10px;">
                                <h1>Raeken Inc.</h1>

                                <a  href="' . $social_fb_url . '"><img style="width:50px;" src="http://raeken.com/assets/images/social-fb-on.png" alt="social-fb-on"></a>
                                <a  href="' . $social_vimeo_url . '"><img style="width:50px;" src="http://raeken.com/assets/images/social-vimeo-on.png" alt="social-vimeo-on"></a>
                                <a  href="' . $social_insta_url . '"><img style="width:50px;" src="http://raeken.com/assets/images/social-insta-on.png" alt="social-insta-on"></a>
                                <a  href="' . $social_twitter_url . '"><img style="width:50px;" src="http://raeken.com/assets/images/social-twitter-on.png" alt="social-twitter-on"></a>

                                <br/>

                                <hr style="border-color: #ededed;border-top: 0;width: 250px;"/>

                                <p><a href="' . $unsubscribe_url . '" style="text-decoration: none;color: #fff;">Unsubscribe</a></p>

                            </div>
                        </body>    
                        ';

            return $str;
        }

    }